﻿using characterCounter;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace characterCounter
{

    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class FirstPage : Page
    {
      
        public FirstPage()
        {
            this.InitializeComponent();
        }

        public void CheckNowButtonClicked(object sender, RoutedEventArgs e)
        {
            this.CountCharacters();
            this.Frame.Navigate(typeof(ResultsPage), null); 
        }

        public void CountCharacters()
        {
            //get the content of the textbox and store it in a string 
            App app = Application.Current as App;
            app.TextBoxValue = TextBoxFirstPage.Text;
            
            //create an array of characters and fill it with the text the user entered
            char[] charArray = app.TextBoxValue.ToCharArray();
            app.CharNumber = charArray.Length;
        }
    }
}
